import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { Website } from './website.entity';

@Entity('events')
export class Event {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  websiteId: number;

  @ManyToOne(() => Website)
  @JoinColumn({ name: 'websiteId' })
  website: Website;

  @Column()
  sessionId: string;

  @Column()
  category: string;

  @Column()
  action: string;

  @Column({ nullable: true })
  label: string;

  @Column({ type: 'float', nullable: true })
  value: number;

  @Column({ nullable: true })
  url: string;

  @Column({ nullable: true })
  ip: string;

  @Column({ nullable: true })
  userAgent: string;

  @Column({ type: 'json', nullable: true })
  customData: Record<string, any>;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
} 